package com.example.web.mapper;

import com.example.web.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //查询用户列表
    @Select("select * from user where is_delete=0")
    List<User> selectAll();

    //插入用户
    @Insert("insert into user(name,date,province,city,address,zip) values(#{name},#{date},#{province},#{city},#{address},#{zip})")
    int insert(User user);

    //更新用户信息
    @Update("update user set name=#{name},province=#{province},city=#{city},address=#{address},zip=#{zip} where id=#{id}")
    int update(User user);

    //删除用户
    @Update("update user set is_delete=1 where id=#{id} and is_delete=0")
    int deleteById(Integer id);

    //根据name模糊查询用户
    @Select("select * from user where name like concat('%',#{name},'%') and is_delete=0")
    List<User> selectByName(String name);
}
